﻿<%@ page contentType="text/html; charset=utf-8" language="java"  %>
<%@ page import="com.cares.core.utils.Constant"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@include file="/static/common/header.jsp"%>
<%@include file="/static/common/easyui.jsp"%>
<script src="${ctx}/static/jquery/jquery.form.js" type="text/javascript"></script>
<link href="${ctx}/static/css/main.css" rel="stylesheet">
<script>

function saveOrgInfo(){
	var r = $('#orgEditForm').form('validate');
	if($("#id").val()!=''&&$("#upOrgId").val()==$("#id").val()){
		showInfoCenter("请重新确认上级机构");
		r=false;
	}
	if(!r) {
		return false;
	}
	$("#orgEditForm").submit();
	progressing();
}
function setUpOrgInfo(){
	openWin3('orgSelectWin','<font color=red >选取上级单位取</font><font color=blue >（双击选取）</font>');
}
function setUpOrgNode(node){
	$("#upOrgId").val(node.id);
	$("#upNameCn").val(node.text);
	$("#upOrgtype").val(node.orgType);
	$('#orgSelectWin').window('close');
}
var ccFlag=false;


var DEP='<%=Constant.ORG_TYPE_DEPARTMENT%>';
var COMP='<%=Constant.ORG_TYPE_COMPANY%>';

$(document).ready(function(){
	<c:if test="${DATA!= null}">
	var jsonStr = jQuery.parseJSON('${DATA}');
	$("#orgEditForm").form("load",jsonStr);	
	</c:if>
	setOrgTypeStyle($("#orgType").val());
	
	$("#orgType").bind("change", function(){
	  var ot=$(this).val();
	  setOrgTypeStyle(ot);
	});
});
function setOrgTypeStyle(ot){
	if(ot==DEP){
	  	$("#upOrgTR").css("display","");
	  }else if(ot==COMP){
	  	$("#upOrgTR").css("display","");
	  }
}
</script>
</head>
<body >
  <form method="post" id="orgEditForm" name="orgEditForm" action="${ctx}/Mng/org/updateOrg">
    <input type="hidden" id="id" name="id" value=""/>
    <table width="100%" cellspacing="0" class="listTable" align="center">
	<tr><th colspan="2">
	<font color=red >管理员注意：原则上机构下可增加机构和部门，部门下只能增加部门</font>
	</th></tr>
	 <tr>
        <td>中文名称</td>
        <td>
          <input name="nameCn" class="easyui-validatebox" type="text" id="nameCn" maxlength="32" required="true" style="width:300px;">        </td>
      </tr>
	 <tr>
        <td>英文名称</td>
        <td>
          <input name="nameEn" class="easyui-validatebox" type="text" id="nameEn" maxlength="32" required="true" style="width:300px;">        </td>
      </tr>
	  <tr>
        <td>机构/部门 代码</td>
        <td><input name="orgCode" class="easyui-validatebox" type="text" id="orgCode" maxlength="32" style="width:300px;" required="true" <shiro:lacksPermission name="____AgentAdmin">  readonly="true" </shiro:lacksPermission>>
		<shiro:hasPermission name="____AgentAdmin"><font color=red ><strong>关键字段</strong></font></shiro:hasPermission>
		<p>此系统中的代码，注意不要重复
		</td>
      </tr>
      <tr>
        <td width="15%">机构类型</td>
        <td>
		<select id="orgType" name="orgType" style="width:200px;">
			<option value="<%=Constant.ORG_TYPE_COMPANY%>">公司</option>
			<option value="<%=Constant.ORG_TYPE_DEPARTMENT%>">部门</option>
          </select>
		</td>
      </tr>
      <tr id="upOrgTR">
        <td>上级机构</td>
        <td><input type="hidden" name="upOrgId" id="upOrgId">
		<input type="hidden" name="upOrgtype" id="upOrgtype">
		<input type="text" class="easyui-validatebox" name="upNameCn" id="upNameCn" readonly="true" onClick="setUpOrgInfo()" style="width:300px;">
		<a class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" href="javascript:void(0);" onClick="setUpOrgInfo()">选取</a>
		</td>
      </tr>
      <tr>
        <td>状态</td>
        <td>
        	<select id="orgState" name="orgState" class="easyui-combobox" style="width:200px;">
				<option value="Y" <c:if test="${'Y' eq orgState}">selected="selected"</c:if>>正常</option>
				<option value="N" <c:if test="${'N' eq orgState}">selected="selected"</c:if>>锁定</option>
          	</select>
        </td>
      </tr>
      <tr>
        <td>排序</td>
        <td><input type="text" name="orgSort" id="orgSort" value="1000" style="width:300px;"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>
		<a href="javascript:void(0);" id="btn-back" onClick="closeParentWindow();" class="easyui-linkbutton" iconcls="icon-back">返回</a>
		<a class="easyui-linkbutton" data-options="iconCls:'icon-save'" href="javascript:void(0);" onClick="saveOrgInfo()">保存</a>		</td>
      </tr>
    </table>
  </form>
  <div id="orgSelectWin" class="easyui-window" data-options="modal:true,closed:true,title:'上级机构选取'" style="width:460px;height:260px;">
    <table id="xxxorgTreeGridData" class="easyui-treegrid"  
			data-options="
				url: '${ctx}/Mng/org/treeGridData',
				rownumbers: true,
				idField: 'id',
				treeField: 'orgCode',fit:true,animate:true,toolbar:'#orgToolbar',onDblClickRow:function(row){setUpOrgNode(row);}
			">
    <thead>
      <tr>
        <th data-options="field:'orgCode'" width="120" align="left">orgCode</th>
		<th data-options="field:'orgType'<shiro:lacksPermission name="____AgentAdmin">,hidden:true</shiro:lacksPermission>" width="150" align="center">orgType</th>
        <th data-options="field:'nameCn'" width="150" >Name</th>
        <th data-options="field:'nameEn'" width="150">nameEn</th>
      </tr>
    </thead>
  </table>
  </div>

